<template>
  <a-modal
    :title="title"
    :width="1200"
    :ok="false"
    :visible="visible"
    :confirmLoading="confirmLoading"
    :okButtonProps="{ props: { disabled: disableSubmit } }"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-spin :spinning="confirmLoading" :class="{ isCheck: disableSubmit, 'a-spin-overflow': true }">
      <a-form-model class="row-label" :rules="validatorRules" :model="model" ref="form" layout="vertical">
        <a-row :gutter="24">
          <a-col span="8">
            <a-form-model-item label="上级机构" prop="parentId">
              <a-tree-select
                style="width: 100%"
                :dropdownStyle="{ maxHeight: '200px', overflow: 'auto' }"
                :treeData="departTree"
                v-model="model.parentId"
                :disabled="disableSubmit"
                placeholder="请选择上级部门"
                :load-data="onLoadData"
              >
              </a-tree-select>
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="机构名称" prop="departName">
              <a-input
                :disabled="disableSubmit"
                id="departName"
                placeholder="请输入机构/部门名称"
                v-model="model.departName"
              />
            </a-form-model-item>
          </a-col>

          <a-col span="8">
            <a-form-model-item prop="detailName" label="单位详细名称">
              <a-input :disabled="disableSubmit" placeholder="请输入单位详细名称" v-model="model.detailName" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col span="8">
            <a-form-model-item label="统一社会信用代码或原组织机构代码" prop="cerdit">
              <a-input
                :disabled="disableSubmit"
                placeholder="请输入统一社会信用代码或原组织机构代码"
                v-model="model.cerdit"
              />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="机构类型" prop="orgType">
              <j-dict-select-tag
                placeholder="请选择机构类型"
                style="width: 100%"
                v-model="model.orgType"
                :disabled="disableSubmit"
                dict-code="sys_office_type"
              />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item prop="isOrg" label="是否审计机构">
              <j-dict-select-tag
                style="width: 100%"
                placeholder="请选择是否审计机构"
                v-model="model.isOrg"
                :disabled="disableSubmit"
                dict-code="yes_not"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col span="8">
            <a-form-model-item label="主要业务活动" prop="yyhd">
              <a-input
                v-for="(item, index) in listItem"
                :key="item.id"
                :style="{ 'margin-top': index == 0 ? '0px' : '10px' }"
                placeholder="请输入主要业务活动"
                :disabled="disableSubmit"
                v-model="item.yyhd"
              />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="行业代码" prop="hydm">
              <a-cascader
                :key="item.id"
                v-for="(item, index) in listItem"
                :style="{ width: '100%', 'margin-top': index == 0 ? '0px' : '10px' }"
                v-model="item.hydm"
                :disabled="disableSubmit"
                :options="HangyeTree"
                placeholder="请选择行业代码"
              />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="操作">
              <div
                :style="{ width: '100%', 'text-align': 'center', 'padding-top': index == 0 ? '0px' : '6px' }"
                :key="item.id"
                v-for="(item, index) in listItem"
              >
                <a-icon
                  v-if="index === 0"
                  :style="{ 'font-size': '24px', color: '#3955a5' }"
                  type="plus-square"
                  @click="handleAddrow"
                />
                <a-icon
                  v-else-if="!(item.id === 0)"
                  type="delete"
                  :style="{ 'font-size': '24px', color: '#3955a5', 'margin-top': index == 0 ? '0px' : '10px' }"
                  @click="handleDelrow(index)"
                />
              </div>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col span="8">
            <a-form-model-item label="省（自治区、直辖市）" prop="province">
              <a-select
                style="width: 100%"
                v-model="model.province"
                placeholder="请选择省（自治区、直辖市）"
                :disabled="disableSubmit"
                @change="getCity"
              >
                <a-select-option v-for="item in provinceList" :key="item.id" :value="item.id">{{
                  item.name
                }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="地（区、市、州、盟）" prop="city">
              <a-select
                style="width: 100%"
                v-model="model.city"
                :disabled="disableSubmit"
                placeholder="请选择地（区、市、州、盟）"
                @change="getCounty"
              >
                <a-select-option v-for="item in cityList" :key="item.id" :value="item.id">{{
                  item.name
                }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item prop="county" label="县（区、市、旗）">
              <a-select
                style="width: 100%"
                :disabled="disableSubmit"
                v-model="model.county"
                placeholder="请选择县（区、市、旗）"
                @change="getTown"
              >
                <a-select-option v-for="item in countyList" :key="item.id" :value="item.id">{{
                  item.name
                }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col span="8">
            <a-form-model-item label="乡（镇）" prop="town">
              <a-select
                style="width: 100%"
                :disabled="disableSubmit"
                v-model="model.town"
                placeholder="请输入乡（镇）"
                @change="getVillage"
              >
                <a-select-option v-for="item in townList" :key="item.id" :value="item.id">{{
                  item.name
                }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="街（村）" prop="village">
              <a-select
                style="width: 100%"
                :disabled="disableSubmit"
                v-model="model.village"
                placeholder="请输入街（村）"
                @change="getVillageName"
              >
                <a-select-option v-for="item in villageList" :key="item.id" :value="item.id">{{
                  item.name
                }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item prop="houseNumber" label="门牌号">
              <a-input placeholder="请输入门牌号" :disabled="disableSubmit" v-model="model.houseNumber" />
            </a-form-model-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col span="8">
            <a-form-model-item prop="qydm" label="区划代码">
              <a-input placeholder="请输入区划代码" :disabled="disableSubmit" v-model="model.qydm" />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="城乡代码" prop="cxdm">
              <a-input placeholder="请输入城乡代码" :disabled="disableSubmit" v-model="model.cxdm" />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="单位规模" prop="dwgm">
              <j-dict-select-tag
                style="width: 100%"
                v-model="model.dwgm"
                :disabled="disableSubmit"
                dict-code="sys_office_dwgm"
                placeholder="请选择单位规模"
              />
            </a-form-model-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col span="8">
            <a-form-model-item prop="cyrs" label="从业人员期末人数（个）">
              <a-input placeholder="请输入从业人员期末人数（个）" :disabled="disableSubmit" v-model="model.cyrs" />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="法定代表人（单位主要负责人）" prop="leader">
              <a-input
                placeholder="请输入法定代表人（单位主要负责人）"
                :disabled="disableSubmit"
                v-model="model.leader"
              />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="执行会计准则类别" prop="kjzelb">
              <j-dict-select-tag
                style="width: 100%"
                v-model="model.kjzelb"
                :disabled="disableSubmit"
                dict-code="sys_office_kjzelb"
                placeholder="请选择执行会计准则类别"
              />
            </a-form-model-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col span="8">
            <a-form-model-item prop="ctqh" label="长途区号">
              <a-input placeholder="请输入长途区号" :disabled="disableSubmit" v-model="model.ctqh" />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item prop="gddh" label="固定电话">
              <a-input placeholder="请输入固定电话" :disabled="disableSubmit" v-model="model.gddh" />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item prop="zipCode" label="邮政编码">
              <a-input placeholder="请输入邮政编码" :disabled="disableSubmit" v-model="model.zipCode" />
            </a-form-model-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col span="8">
            <a-form-model-item prop="email" label="电子邮箱">
              <a-input placeholder="请输入电子邮箱" :disabled="disableSubmit" v-model="model.email" />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="邮箱网址" prop="emailAddr">
              <a-input placeholder="请输入邮箱网址" :disabled="disableSubmit" v-model="model.emailAddr" />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="本法人单位是否有上一级法人" prop="issjfr">
              <j-dict-select-tag
                placeholder="请选择本法人单位是否有上一级法人"
                style="width: 100%"
                :disabled="disableSubmit"
                v-model="model.issjfr"
                dict-code="yes_not"
              />
            </a-form-model-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col span="8">
            <a-form-model-item prop="sjcredit" label="上一级法人单位统一社会信用代码（或原组织结构代码）">
              <a-input
                placeholder="请输入上一级法人单位统一社会信用代码（或原组织结构代码）"
                v-model="model.sjcredit"
                :disabled="disableSubmit"
              />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="上一级法人单位详细名称" prop="sjfr">
              <a-input placeholder="请输入上一级法人单位详细名称" :disabled="disableSubmit" v-model="model.sjfr" />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="总审计设置情况" prop="zsjqk">
              <j-dict-select-tag
                placeholder="请选择总审计设置情况"
                style="width: 100%"
                v-model="model.zsjqk"
                :disabled="disableSubmit"
                dict-code="yes_not"
              />
            </a-form-model-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col span="8">
            <a-form-model-item label="总审计师职位层级（领导班子等）" prop="zsjzw">
              <j-dict-select-tag
                placeholder="请选择总审计师职位层级（领导班子等）"
                style="width: 100%"
                :disabled="disableSubmit"
                v-model="model.zsjzw"
                dict-code="sys_office_zsjzw"
              />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item prop="zsjrz" label="总审计师任职方式（上一级法人单位委派等）">
              <j-dict-select-tag
                placeholder="请选择总审计师任职方式（上一级法人单位委派等）"
                style="width: 100%"
                :disabled="disableSubmit"
                v-model="model.zsjrz"
                dict-code="sys_office_zsjrz"
              />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item prop="nbsjsz" label="内部审计机构设置">
              <j-dict-select-tag
                placeholder="请选择内部审计机构设置"
                style="width: 100%"
                :disabled="disableSubmit"
                v-model="model.nbsjsz"
                dict-code="yes_not"
              />
            </a-form-model-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col span="8" v-show="model.nbsjsz == 1">
            <a-form-model-item prop="jtmc" label="具体名称">
              <a-input placeholder="具体名称" :disabled="disableSubmit" v-model="model.jtmc" />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="内部审计工作领导机构" prop="nbsjld">
              <j-dict-select-tag
                placeholder="请选择内部审计工作领导机构"
                style="width: 100%"
                :disabled="disableSubmit"
                v-model="model.nbsjld"
                dict-code="sys_office_nbsjld"
              />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="独立审计机构设置" prop="dlsjjg">
              <j-dict-select-tag
                placeholder="请选择独立审计机构设置"
                style="width: 100%"
                :disabled="disableSubmit"
                v-model="model.dlsjjg"
                dict-code="yes_not"
              />
            </a-form-model-item>
          </a-col>
          <a-col span="8" v-show="model.dlsjjg == 1">
            <a-form-model-item label="合并设置职能部门" prop="hbznbm">
              <j-dict-select-tag
                placeholder="请选择并设置职能部门"
                style="width: 100%"
                :disabled="disableSubmit"
                v-model="model.hbznbm"
                dict-code="sys_office_hbznbm"
              />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item prop="nbsjcj" label="内部审计机构层级">
              <a-input placeholder="请输入内部审计机构层级" :disabled="disableSubmit" v-model="model.nbsjcj" />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item prop="nbsjcj" label="序号">
              <a-input-number
                style="width: 100%"
                placeholder="请输入序号"
                :disabled="disableSubmit"
                v-model="model.departOrder"
              />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item prop="nbsjcj" label="机构编码">
              <a-input placeholder="请输入机构编码" :disabled="disableSubmit" v-model="model.orgCode" />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item label="是否含有审计人员" prop="isAuditPerson">
              <j-dict-select-tag
                placeholder="请选择是否含有审计人员"
                style="width: 100%"
                :disabled="disableSubmit"
                v-model="model.isAuditPerson"
                dict-code="yes_not"
              />
            </a-form-model-item>
          </a-col>
          <a-col span="8">
            <a-form-model-item prop="status" label="是否可用">
              <a-switch @change="handleswich" :disabled="disableSubmit" :checked="model.status == '1'" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col span="8">
            <a-form-model-item prop="processtype" label="流程审批">
              <a-radio-group v-model="model.processtype" :disabled="disableSubmit">
                <a-radio :value="0">全局设置</a-radio>
                <a-radio :value="1">单位定义</a-radio>
              </a-radio-group>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col>
            <a-form-model-item
              :labelCol="{ sm: { span: 2 } }"
              :wrapperCol="{ sm: { span: 22 } }"
              prop="memo"
              label="备注"
            >
              <a-textarea :disabled="disableSubmit" v-model="model.memo" :auto-size="{ minRows: 3, maxRows: 5 }" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
  </a-modal>
</template>

<script>
import { httpAction, getAction } from '@/api/manage'
import { queryUpTree, queryUpTreeLazy } from '@/api/api'
import _ from 'lodash'
import { mapGetters } from 'vuex'

export default {
  name: 'SysDepartModal',
  data() {
    return {
      value: '',
      departTree: [],
      HangyeTree: [],
      departName: '',
      title: '',
      // seen:false,
      visible: false,
      disableSubmit: false,
      model: {
        hdhydm: '',
        cerdit: '',
        city: undefined,
        county: undefined,
        ctqh: '',
        cxdm: '',
        cyrs: '',
        departName: '',
        detailName: '',
        processtype: 0,
        dlsjjg: '',
        dwgm: '',
        email: '',
        emailAddr: '',
        gddh: '',
        hbznbm: '',
        houseNumber: '',
        isOrg: '',
        issjfr: '',
        jtmc: '',
        kjzelb: '',
        memo: '',
        nbsjcj: '',
        nbsjld: '',
        nbsjsz: '',
        orgType: '',
        parentId: undefined,
        leader: '',
        province: undefined,
        qydm: '',
        sjcredit: '',
        sjfr: '',
        status: '0',
        town: '',
        village: '',
        zipCode: '',
        zsjqk: '',
        zsjrz: '',
        zsjzw: '',
        xu: '',
        jg: '',
      },
      defaultModel: {
        departOrder: 0,
        // orgCategory:'1'
      },
      address: {
        provinceName: '',
        countyName: '',
        cityName: '',
        townName: '',
        villageName: '',
      },
      labelCol: {
        sm: { span: 8 },
      },
      wrapperCol: {
        sm: { span: 16 },
      },
      listItem: [
        {
          id: 0,
          yyhd: '',
          hydm: [],
        },
      ],
      confirmLoading: false,
      validatorRules: {
        // emailAddr: [{ required: false, validator: this.validateMobile }],
        // email: [{ required: false, validator: this.validateEmail }],
        ctqh: [{ required: false, validator: this.validateCtqh }],
        gddh: [{ required: false, validator: this.validateGddh }],
        zipCode: [{ required: false, validator: this.validateZipCode }],
        cyrs: [{ required: false, validator: this.validateCyrs }],
      },
      provinceList: [],
      cityList: [],
      countyList: [],
      townList: [],
      villageList: [],
      rowData: null,
      url: {
        add: '/sys/sysDepart/add',
        // 获取数据
        address: '/sys/sysDepart/listAddress',
        detail: '/sys/sysDepart/queryDeptTreeDetail',
        edit: '/sys/sysDepart/edit',
        Hangye: '/sys/sysDepart/queryTreeSysHangye',
      },
    }
  },
  created() {},
  computed: {
    formDisabled() {
      return this.disableSubmit
    },
  },
  methods: {
    ...mapGetters(['departInfo']),
    getrequset() {
      // 请求行业树
      this.loadHangyeTreeData()
      // 上级单位树
      this.loadTreeData()
    },
    getaddRecoed(pid) {
      return getAction(this.url.address, { pid })
    },
    getDetailRecord(id) {
      getAction(this.url.detail, { id }).then((res) => {
        if (res.success) {
          this.provinceList = res.result.province
          this.cityList = res.result.citys
          this.countyList = res.result.countys
          this.townList = res.result.towns
          this.villageList = res.result.villages
          this.listItem = JSON.parse(res.result.data.hdhydm)
          this.model = Object.assign({}, res.result.data)
        } else {
          this.$message.success(res.message)
        }
      })
    },
    validateEmail(rule, value, callback) {
      let E_REGEXP = /^[0-9a-zA-Z]+([\.\-_]*[0-9a-zA-Z]+)*@([0-9a-zA-Z]+[\-_]*[0-9a-zA-Z]+\.)+[0-9a-zA-Z]{2,6}$/
      if (!value) {
        callback()
      } else if (!E_REGEXP.test(value)) {
        callback('邮箱格式不正确')
      } else {
        callback()
      }
    },
    validateCtqh(rule, value, callback) {
      let C_REGEXP = /^\d{3,4}$/
      if (!value) {
        callback()
      } else if (!C_REGEXP.test(value)) {
        callback('长途区号格式不正确')
      } else {
        callback()
      }
    },
    validateGddh(rule, value, callback) {
      let G_REGEXP = /^\d{7,8}$/
      if (!value) {
        callback()
      } else if (!G_REGEXP.test(value)) {
        callback('固定电话格式不正确')
      } else {
        callback()
      }
    },
    validateZipCode(rule, value, callback) {
      let Z_REGEXP = /^[1-9]\d{5}$/
      if (!value) {
        callback()
      } else if (!Z_REGEXP.test(value)) {
        callback('邮政编码格式不正确')
      } else {
        callback()
      }
    },
    validateCyrs(rule, value, callback) {
      let Num_REGEXP = /^\d+$/
      if (!value) {
        callback()
      } else if (!Num_REGEXP.test(value)) {
        callback('请输入不带小数点的整数')
      } else {
        callback()
      }
    },
    handleswich(checked) {
      this.model.status = checked ? '1' : '0'
    },
    handleAddrow: _.throttle(function () {
      if (!this.disableSubmit) {
        this.listItem.push({
          id: Date.now(),
          yyhd: '',
          hydm: [],
        })
      }
    }, 500),
    handleDelrow: _.throttle(function (index) {
      if (!this.disableSubmit) {
        console.log(index)
        this.listItem.splice(index, 1)
      }
    }, 500),
    add() {
      this.rowData = null
      this.model = this.$options.data().model
      this.listItem = [...this.$options.data().listItem]
      this.getrequset()
      // 首次获取省份
      this.getProvince(0)
      this.visible = true
    },
    edit(record) {
      this.rowData = record
      this.visible = true
      this.getDetailRecord(record.id)
      this.getrequset()
    },
    check(record) {
      this.rowData = record
      this.visible = true
      this.getDetailRecord(record.id)
      this.getrequset()
    },
    close() {
      this.$emit('close')
      this.disableSubmit = false
      this.visible = false
      this.$refs.form.resetFields()
    },
    loadTreeData() {
      this.departTree = []
      let params = {
        ifRoot: true,
        id: !this.rowData || !this.rowData.parentId ? this.departInfo().parentId : this.rowData.parentId
      }
      queryUpTreeLazy(params).then((res) => {
        if (res.success) {
          for (let i = 0; i < res.result.length; i++) {
            let temp = res.result[i]
            this.departTree.push(temp)
          }
        }
      })
    },
    onLoadData(node) {
      let params = {
        ifRoot: false,
        id: node.value
      }
      return new Promise(resolve => {
        queryUpTreeLazy(params).then((res) => {
          if (res.success) {
            const targetNode = this.findNodeByValue(this.departTree, node.value)
            if (res.result && res.result.length > 0) {
              targetNode.children = res.result
            }
            resolve()
          }
        })
      })
    },
    findNodeByValue(tree, value) {
      for (let node of tree) {
        if (node.value === value) return node
        if (node.children) {
          const found = this.findNodeByValue(node.children, value)
          if (found) return found
        }
      }
      return null
    },
    loadHangyeTreeData() {
      getAction(this.url.Hangye).then((res) => {
        if (res.success) {
          this.HangyeTree = res.result || []
        }
      })
    },
    handleOk() {
      const that = this
      // 触发表单验证
      let data = _.cloneDeep(this.listItem)
      data.map((item) => {
        delete item.id
      })
      this.findName()
      debugger
      this.$refs.form.validate((valid) => {
        debugger
        if (valid) {
          let { provinceName, countyName, cityName, townName, villageName } = this.address
          that.confirmLoading = true
          let model = Object.assign({}, this.model, {
            hdhydm: JSON.stringify(data),
            address: `${provinceName || ''}${countyName || ''}${cityName || ''}${townName || ''}${villageName || ''}${
              this.model.houseNumber || ''
            }`,
          })
          //  数据不存在 新增
          if (!this.model.id) {
            httpAction(this.url.add, model, 'post')
              .then((res) => {
                if (res.success) {
                  that.$message.success(res.message)
                  that.loadTreeData()
                  that.$emit('ok')
                } else {
                  that.$message.warning(res.message)
                }
              })
              .finally(() => {
                that.confirmLoading = false
                that.close()
              })
          } else {
            httpAction(this.url.edit, model, 'put')
              .then((res) => {
                if (res.success) {
                  that.$message.success(res.message)
                  that.loadTreeData()
                  that.$emit('ok')
                } else {
                  that.$message.warning(res.message)
                }
              })
              .finally(() => {
                that.confirmLoading = false
                that.close()
              })
          }
        } else {
          this.$message.warning('请确保输入数据格式正确')
          return false
        }
      })
    },
    //  获取省份
    async getProvince(pid) {
      let res = await this.getaddRecoed(pid)
      this.provinceList = res.result
    },
    //  获取地份
    async getCity(pid, Vnode) {
      // this.address.provinceName = Vnode.componentOptions.children[0].text
      let res = await this.getaddRecoed(pid)
      this.cityList = res.result
    },
    //  获取县份
    async getCounty(pid, Vnode) {
      // this.address.cityName = Vnode.componentOptions.children[0].text
      let res = await this.getaddRecoed(pid)
      this.countyList = res.result
    },
    // 获取乡镇
    async getTown(pid, Vnode) {
      // this.address.countyName = Vnode.componentOptions.children[0].text
      let res = await this.getaddRecoed(pid)
      this.townList = res.result
    },
    // 获取街道
    async getVillage(pid, Vnode) {
      // this.address.townName = Vnode.componentOptions.children[0].text
      let res = await this.getaddRecoed(pid)
      this.villageList = res.result
    },
    getVillageName(pid, Vnode) {
      // this.address.villageName = Vnode.componentOptions.children[0].text
      console.log(this.address)
    },
    findName() {
      this.provinceList.map((item) => {
        if (item.id === this.model.province) {
          this.address.provinceName = item.name
        }
      })
      this.cityList.map((item) => {
        if (item.id === this.model.city) {
          this.address.countyName = item.name
        }
      })
      this.countyList.map((item) => {
        if (item.id === this.model.county) {
          this.address.cityName = item.name
        }
      })
      this.townList.map((item) => {
        if (item.id === this.model.town) {
          this.address.townName = item.name
        }
      })
      this.villageList.map((item) => {
        if (item.id === this.model.village) {
          this.address.villageName = item.name
        }
      })
    },
    handleCancel() {
      this.close()
    },
    validateMobile(rule, value, callback) {
      if (!value || new RegExp(/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/).test(value)) {
        callback()
      } else {
        callback('您的手机号码格式不正确!')
      }
    },
  },
}
</script>

<style lang="less" scoped>
// @import '~@/views/sj/css/checkAndEdit.less';
.isCheck {
  /deep/.ant-input-disabled {
    background-color: white;
    color: black;
  }
  /deep/.ant-select-disabled .ant-select-selection {
    background-color: white;
    color: black;
  }

  /deep/.ant-cascader-picker-disabled {
    background-color: white;
    color: black;
  }
}
.a-spin-overflow {
  height: 540px;
  overflow-y: scroll;
  overflow-x: hidden;
}
</style>